<?php
// +----------------------------------------------------------------------
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
// +----------------------------------------------------------------------
// | Copyright (c) 2006~2018 http://thinkphp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: liu21st <liu21st@gmail.com>
// +----------------------------------------------------------------------

//不需要验证token
Route::group('admin/:version',function(){
//   后端登录
    Route::post('login','admin/:version.Manager/login');
})->allowCrossDomain();
//验证登录
Route::group('admin/:version',function(){
    //退出登录

    //获取管理员登录信息
    Route::get('getinfo','admin/:version.Manager/getinfo');
})->allowCrossDomain([
    'Access-Control-Allow-Headers' => 'token'
])->middleware(\app\common\middleware\hasManagerLogin::class);

//需要验证权限
Route::group('admin/:version',function(){
    //管理员相关
    //获取管理员
    Route::get('manager/:page','admin/:version.Manager/index');
    //菜单相关
    //获取菜单
    Route::get('menus/:page','admin/:version.Rule/index');
    //删除菜单
    Route::post('menus/:id/delete','admin/:version.Rule/delete');
    //增加菜单
    Route::post('menus/save','admin/:version.Rule/save');
    //修改菜单
    Route::post('menus/:id/update','admin/:version.Rule/update');

    //角色相关
    //获取角色
    Route::get('role/:page','admin/:version.Role/index');
    //删除角色
    Route::post('role/:id/delete','admin/:version.Role/delete');
    //增加角色
    Route::post('role/save','admin/:version.Role/save');
    //修改角色
    Route::post('role/:id/update','admin/:version.Role/update');

    //协议相关
    //获取协议
    Route::get('agreement/:page','admin/:version.Agreement/index');
    //添加协议
    Route::post('agreement/save','admin/:version.Agreement/save');
    //修改协议
    Route::post('agreement/:id/update','admin/:version.Agreement/update');
    //删除协议
    Route::post('agreement/:id/delete','admin/:version.Agreement/delete');

    //轮播图相关
    Route::get('banner/:page','admin/:version.Banner/index');
    //添加轮播图
    Route::post('banner/save','admin/:version.Banner/save');


    //商品分类相关
    //获取商品分类列表
    Route::get('catetype/:page','admin/:version.Catetype/index');
    //添加商品分类
    Route::post('catetype/save','admin/:version.Catetype/save');
//修改商品分类
    Route::post('catetype/:id/update','admin/:version.Catetype/update');

    //上传文件
    Route::post('upload','admin/:version.UploadFile/upload');
})->allowCrossDomain([
    'Access-Control-Allow-Headers' => 'token'
])->middleware(\app\common\middleware\checkManagerToken::class);